<?php

{% include 'header.tpl' %}

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

/**
 * HelloWorlds View
 */
class {{ config.component.name|capitalize }}View{{ entity.name|capitalize}}list extends JView
{
	protected $items;
	protected $pagination;
	protected $state;
	
	/**
	 * HelloWorlds view display method
	 * @return void
	 */
	function display($tpl = null) 
	{
		// Get data from the model
		$this->items = $this->get('Items');
		$this->pagination = $this->get('Pagination');
		$this->state = $this->get('State');
		
		// Check for errors.
		if (count($errors = $this->get('Errors'))) 
		{
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}
		// Set the toolbar
		$this->addToolBar();

		// Display the template
		parent::display($tpl);

		// Set the document
		$this->setDocument();
	}

	/**
	 * Setting the toolbar
	 */
	protected function addToolBar() 
	{
		JToolBarHelper::title(JText::_('COM_{{ config.component.name|upper}}_LIST_{{ entity.name|upper }}'));
		JToolBarHelper::deleteListX('', '{{ entity.name|lower}}list.delete');
		JToolBarHelper::editListX('{{ entity.name|lower}}.edit');
		JToolBarHelper::addNewX('{{ entity.name|lower}}.add');
	}
	/**
	 * Method to set up the document properties
	 *
	 * @return void
	 */
	protected function setDocument() 
	{
		$document = JFactory::getDocument();
		$document->setTitle(JText::_('{{ config.component.title }}'));
	}
}
